package com.isunland.managesystem.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.EmployeeLoanContent;
import com.isunland.managesystem.utils.MyStringUtil;
import com.isunland.managesystem.utils.MyUtils;
import java.util.ArrayList;

//public class EmployeeLoanListAdapter extends BaseShadowListAdapter<EmployeeLoanContent> {
//
//    public EmployeeLoanListAdapter(Context context, List<EmployeeLoanContent> objects) {
//        super(context, objects);
//    }
//
//    @Override
//    public void bindData(int position, ViewHolder vh, EmployeeLoanContent item) {
//        MyUtils.switchShadowStutus(getContext(),vh.mContentStatusTv,item.getDataStatus());
//        vh.mContentTwoTv.setText(item.getCertificateNo());
//        vh.mContentTwoTv.setTextColor(getContext().getResources().getColor(R.color.chocolate));
//        vh.mContentThreeTv.setText(item.getExpenseDesc());
//        vh.mPersonNameTv.setText(item.getApplicantName());
//        vh.mPersonDataTv.setText(item.getApplyTime());
//    }
//}
public class EmployeeLoanListAdapter extends BaseButterKnifeAdapter<EmployeeLoanContent> {

  private Context context;

  public EmployeeLoanListAdapter(BaseVolleyActivity context,
      ArrayList<EmployeeLoanContent> objects) {
    super(context, objects);
    this.context = context;
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_loan_item;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override
  protected void initView(EmployeeLoanContent item, BaseViewHolder baseHolder, int position) {
    ViewHolder holder = (ViewHolder) baseHolder;

    MyUtils.switchShadowStutus(context, holder.tvStatus, item.getDataStatus());//数据状态
    holder.tvTitle.setText(item.getCertificateNo());//编码
    if (!TextUtils.isEmpty(item.getExpenseDesc())) {
      holder.tvContent1.setVisibility(View.VISIBLE);
      holder.tvContent1.setText(item.getExpenseDesc());//费用摘要
    } else {
      holder.tvContent1.setVisibility(View.GONE);
    }
    if ((item.getCertificateCode()).contains("DJLB-CWSR-HKSR")){
      //还款
      holder.tvMoney.setText(
          MyStringUtil.connect(item.getInAmount(), context.getString(R.string.yuan)));//总计实际报销
    }else {
      //其他借款
      holder.tvMoney.setText(
          MyStringUtil.connect(item.getPoutAmount(), context.getString(R.string.yuan)));//总计实际报销
    }

    holder.tvBottomLeft.setText(
        MyStringUtil.connect(item.getRegStaffName(), MyStringUtil.SEPEREATE, item.getRegDate()));
  }

  class ViewHolder extends BaseViewHolder {
    @BindView(R.id.tv_title) TextView tvTitle;
    @BindView(R.id.tv_status) TextView tvStatus;
    @BindView(R.id.tv_content1) TextView tvContent1;
    @BindView(R.id.tv_money) TextView tvMoney;
    @BindView(R.id.tv_bottomLeft) TextView tvBottomLeft;
    @BindView(R.id.tv_bottomRight) TextView tvBottomRight;

    ViewHolder(View view) {
      super(view);
      ButterKnife.bind(this, view);
    }
  }
}
